package com.example.mvvmkotlin.db.initdb

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.example.mvvmkotlin.UserBean
import com.example.mvvmkotlin.application.BaseApplication
import com.example.mvvmkotlin.databinding.ActivityDbBinding

//https://huaweicloud.csdn.net/65095690993dd34278ee3abc.html?dp_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MzQ0ODA0MCwiZXhwIjoxNjk1OTcxOTk4LCJpYXQiOjE2OTUzNjcxOTgsInVzZXJuYW1lIjoibTBfNTQ1OTc1NDIifQ.mn04C6v5KdsHzA5AjJ2idqFPUs5Z7Mh6vjh2A6XPpW8
class DbActivity : AppCompatActivity() {
    private lateinit var binding: ActivityDbBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityDbBinding.inflate(layoutInflater)
        setContentView(binding.root)
        val allUsers = BaseApplication.instance().getDaoSession().userBeanDao.loadAll()
        if (allUsers.isEmpty()){
            val userBean = UserBean(1L, "123", "123456")
            BaseApplication.instance().getDaoSession().userBeanDao.insert(userBean)
        }

    }
}